<!DOCTYPE html>
<html>
<head>
	<include file="Public:common-css" />
	<link type="text/css" rel="stylesheet" href="__ICSS__/login.css" />
</head>
<body>
<div class="container">
<!-------------------------header--------------------------------->
<div class="header-wrap">
    <div class="header2">
        <div class="logo2"><a href="__ROOT__"></a><span>找回密码</span></div>
    </div>
</div>
<!-------------------------header-end----------------------------->
<div class="clr"></div>
<!--------------------------content------------------------------->
	<div class="lr-box">
    	<div class="login-content">
        	<div class="find-pwd-wrap">
	            <div class="login">
	            	<form action="__URL__/updatePassword" method="post" class="registerForm">
	                    <p class="message" style="display:none;"></p>
	                    <div class="item-box"><div class="item-title">手机号码</div><p class="check-success"><input type="text" class="l-input phonenum" placeholder="请输入手机号"  nullmsg="请填写您的手机号码" sucmsg="通过验证" name="tel" datatype="e" ajaxurl="__URL__/checkTel2" /><b class="phone-icon"></b></p></div>
	                    <div class="item-box">
	                    	<div class="item-title">验证码</div>
		                    <p class="check-success tel-code-box">
		                    	<input type="text" class="l-input phone-code-input" id="tel_code" placeholder="验证码" name="tel_code" datatype="e" nullmsg="请输入手机验证码" />
		                    	<input type="button" id="phone-btn" class="phone-code-button" value="获取手机验证码"/><em id="em_code" class="em-code-success"></em>
		                    	<b class="referrer-icon"></b>
		                    </p>
	                    </div>
	                    <div class="item-box"><div class="item-title">新密码</div><p class="check-success"><input type="password" class="l-input password1" placeholder="请输入密码(6-20位英文数字)" nullmsg="请输入密码(6-20位英文数字)" sucmsg="可以使用" name="password"/><b class="password-icon"></b></p></div>
	                    <div class="item-box"><div class="item-title">确认密码</div><p class="check-success"><input type="password" class="l-input password2" placeholder="确认密码" nullmsg="请确认密码" sucmsg="通过验证" name="password2"/><b class="password-icon"></b></p></div>
	                    <p><input type="submit" id="btn" value="立即找回" class="submit-btn register-btn"/></p>
	                    <button type="reset" id="reset2" style="display:none;" class="btn btn-success btn-block">重置</button>
	                </form>
	                <div class="clearfix"></div>
	            </div>
            </div>
        </div>
        <div class="clr"></div>
    </div>
<!--------------------------content-end--------------------------->
    <include file="Public:footer" />
</div>

</body>
<include file="Public:common-js" />
<script type="text/javascript" src="__IJS__/Validform_v5.3.2_min.js" ></script>
<script type="text/javascript">
$(function(){
	$(".register-btn").click(function (){
		if(!testSpace($(".phonenum").val())){
			layer.msg("手机号码中含有空格字符，请重新检查");
			$('input[name="tel"]').focus();
			return false;
		}
		function testSpace(str){
			if(str.indexOf(" ") >= 0){
				return false;
			}else{
				return true;
			}
		}
	})
	$("#reset2").click();
	//表单验证
	var form=$(".registerForm").Validform({
		btnSubmit:".register-btn", 
		tiptype:3,
		label:".label",
		showAllError:false,
		postonce:true,
		datatype:{
			"p6-20":/^[a-z0-9A-Z]{6,20}$/
			
		},
		ajaxPost:true,
		callback:function(data){
			if(data.status == 1){
				window.location.href = "__ROOT__/Login/success"
			}else{
				layer.alert(data.info);
			}
		}
	});
	form.tipmsg.w["p6-20"]="密码格式为6到20位英文数字！";
	form.addRule([{
		ele:".phonenum",
		datatype:"m"
	},
	{
		ele:".phone-code-input",
		datatype:"s6-6"	
	},
	{
		ele:".password1",
		datatype:"p6-20"
	},
	{
		ele:".password2",
		datatype:"p6-20",
		recheck:"password"
	}]);
	$("#reflesh").click(function(){
		fleshVerify();
	})
	
		
	//发送成功请等待 
	$("#phone-btn").click(function() {
		var telIpt = $('input[name="tel"]');
		//判断手机是否验证通过
		if($(".registerForm").Validform().check(true,telIpt) && telIpt.Validform().eq(0).forms[0].validform_valid == "true"){
			$.ajax({
				url:"__ROOT__/Login/sendPhoneCode",
				type:"post",
				data:{tel:telIpt.val()},
				success:function(data){
					if(data.status == 1){
						$("#em_code").attr("class","em-code-error");
						$("#em_code").html(data.info);
					}else{
						$("#em_code").attr("class","em-code-success");
						$("#em_code").html("");
					}
				}
			})
			countDown(this);
		}else{
			layer.msg("手机号格式不正确或已被注册!");
			
		}
	});

})
//倒计时
var wait= 60;
function countDown(t){
	if (wait == 0) {
		$("#phone-btn").attr("class","phone-code-button");
		t.removeAttribute("disabled");			
		t.value="获取手机验证码";
		wait = 60;
	} else {
		t.setAttribute("disabled", true);
		$("#phone-btn").attr("class","phone-code-button-off");
		t.value="重新发送(" + wait + ")";
		wait--;
		setTimeout(function() {
			countDown(t)
		},1000)
	}
}

</script>

</html>
